﻿#region Header
// Copyright 2007-2011, Jerónimo Milea
// 
// This file is part of NetJsWire.
// 
//     NetJsWire is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     NetJsWire is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with NetJsWire.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using NetJsWire.JsonRpcHandler;
using NetJsWire.Widgets.Ui.List;

namespace NetJsWire.Widgets.Config
{
    [Description( "ListView - Config options" )]
    public class ListViewConfigOptions : DataViewConfigOptions
    {
        private object _columnResize = true;
        private object _columnSort = true;
        private ListViewColumnCollection _columns;

        public ListViewConfigOptions( IWidget ownerWidget )
            : base( ownerWidget )
        {
            _columns = new ListViewColumnCollection( ( ListView ) ownerWidget );
        }

        [Editor( typeof( CollectionEditor ), typeof( UITypeEditor ) )]
        [Browsable( true )]
        [DesignerSerializationVisibility( DesignerSerializationVisibility.Visible )]
        public override ListViewColumnCollection Columns
        {
            get { return _columns; }
            set { _columns = value; }
        }

        /// <summary>
        ///   Specify true or specify a configuration object for Ext.list.ListView.ColumnResizer to enable the columns to be resizable (defaults to true).
        /// </summary>
        [Description( "Specify true or specify a configuration object for Ext.list.ListView.ColumnResizer to enable the columns to be resizable (defaults to true)." )]
        [DefaultValue( true )]
        [Browsable( true )]
        [TypeConverter( typeof( StringConverter ) )]
        public override object ColumnResize
        {
            get { return _columnResize; }
            set
            {
                SetValue( "columnResize", value, true, _columnResize );
                _columnResize = value;
            }
        }

        /// <summary>
        ///   Specify true or specify a configuration object for Ext.list.ListView.Sorter to enable the columns to be sortable (defaults to true).
        /// </summary>
        [Description( "Specify true or specify a configuration object for Ext.list.ListView.Sorter to enable the columns to be sortable (defaults to true)." )]
        [DefaultValue( true )]
        [Browsable( true )]
        [TypeConverter( typeof( StringConverter ) )]
        public override object ColumnSort
        {
            get { return _columnSort; }
            set
            {
                SetValue( "columnSort", value, true, _columnSort );
                _columnSort = value;
            }
        }


        /// <summary>
        ///   The registered xtype to create.
        ///   This config option is not used when passing a config object into a constructor.
        ///   This config option is used only when lazy instantiation is being used, and a child item of a Container is being specified not as a fully instantiated Component, but as a Component config object.
        ///   The xtype will be looked up at render time up to determine what type of child Component to create.
        /// </summary>
        [Description( "The registered xtype to create. This config option is not used when passing a config object into a constructor." )]
        [Browsable( true )]
        [DefaultValue( "listview" )]
        [TypeConverter( typeof( XtypeStringConverter ) )]
        public override string Xtype
        {
            get
            {
                return base.Xtype;
            }
            set
            {
                base.Xtype = value;
            }
        }

    }
}
